{% extends "tardis_portal/search_template.html" %}

{% block searchPageBody %}

  {% if not paginator.object_list.count %}
    No datafiles found
  {% else %}
    <strong>{{ paginator.object_list.count }}</strong> result{{ paginator.object_list.count|pluralize }} found
    <table class="results-table">
      <tr>
	<th>Filename</th>
	<th>Dataset</th>
	<th>Experiment</th>
      </tr>
      {% for datafile in datafiles.object_list %}
        <tr>
	  <th>
	    {% if datafile.protocol %}
	      <a class="filelink" href="/{{datafile.protocol}}/download/datafile/{{datafile.id}}/">{{ datafile.filename }}</a> -
	    {% else %}
  	      <a class="filelink" href="{% url tardis.tardis_portal.download.download_datafile datafile.id %}/">{{ datafile.filename }}</a>
	    {% endif %}
	    {% if datafile.size %}
	      ({{ datafile.size|filesizeformat }})
	    {% endif %}
	  </th>
	  <td> {{datafile.dataset.description}} </td>
	  <td> <a href="{% url tardis.tardis_portal.views.view_experiment datafile.dataset.experiment.id %}">{{datafile.dataset.experiment.title}}</a> </td>
	</tr>
	{% endfor %}
    </table>
    <div class="pagination">
      <span class="step-links">
	{% if datafiles.has_previous %}
	  <a href="?{{ query_string }}&page={{ datafiles.previous_page_number }}">previous</a>
	{% endif %}
	<span class="current">
	  Page {{ datafiles.number }} of {{ datafiles.paginator.num_pages }}.
	</span>
	{% if datafiles.has_next %}
	  <a href="?{{ query_string }}&page={{ datafiles.next_page_number }}">next</a>
	{% endif %}
      </span>
    </div> <!-- pagination -->
  {% endif %}
{% endblock %}
